package cc.gpai.util.slotboard;

import java.lang.reflect.Proxy;
import java.util.Arrays;

@SuppressWarnings("rawtypes")
public class CustomSignal<E> extends AbstractSignal<E> {
	private final Object proxy;

	public CustomSignal(Class[] clz) {
		super();
		proxy = Proxy.newProxyInstance(getClass().getClassLoader(), clz, this);
		for (Class clazz : clz) {
			methods.addAll(Arrays.asList(clazz.getMethods()));
		}
	}

	public <T> T as(Class<T> clz) {
		if (clz == null) {
			throw new NullPointerException();
		}
		return clz.cast(proxy);
	}

}
